package com.gavindon.android.viewmodel

import androidx.lifecycle.viewModelScope
import com.gavindon.android.base.BaseViewModel
import com.gavindon.android.entity.SmartEducationContentResp
import com.gavindon.android.entity.SmartLeftTreeResp
import com.gavindon.android.entity.VideoDetail
import com.gavindon.android.network.DataResult
import com.gavindon.android.repo.SmartEducationRepo
import kotlinx.coroutines.launch

/**
 * description:
 * Created by liNan on  2022-2-7 09:46
 */
class SmartEducationViewModel : BaseViewModel() {

    private val repo = SmartEducationRepo()


    private val leftTreeLiveData = SingleLiveEvent<DataResult<List<SmartLeftTreeResp>>>()

    private val courseLstLiveData = SingleLiveEvent<DataResult<List<SmartEducationContentResp>>>()
    fun getLeftTree(type:Int): SingleLiveEvent<DataResult<List<SmartLeftTreeResp>>> {
        viewModelScope.launch {
            val resp = repo.getLeftTree(type)
            leftTreeLiveData.postValue(resp)
        }
        return leftTreeLiveData
    }

    /**
     * 获取课程列表
     */
    fun getCourseLst(subjectId: String): SingleLiveEvent<DataResult<List<SmartEducationContentResp>>> {
        viewModelScope.launch {
            val resp = repo.getCourseList(subjectId)
            courseLstLiveData.postValue(resp)
        }
        return courseLstLiveData
    }
}